﻿using System;
using System.Text.RegularExpressions;
using System.Xml.Serialization;

namespace Neovolve.Extensibility.VisualStudio.TestProfilerLink
{
    /// <summary>
    /// The <see cref="Profiler"/>
    /// class is used to describe a profiler application.
    /// </summary>
    [Serializable]
    public class Profiler : ApplicationBase
    {
        private String _commandName;

        /// <summary>
        /// Gets the name of the command.
        /// </summary>
        /// <value>The name of the command.</value>
        public String CommandName
        {
            get
            {
                if (String.IsNullOrEmpty(_commandName))
                {
                    const String InvalidCharacterPattern = @"\W";
                    
                    _commandName = Regex.Replace(Name, InvalidCharacterPattern, String.Empty);
                }

                return _commandName;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the profiler icon should be extracted and used.
        /// </summary>
        /// <value><c>true</c> if the profiler icon should be used; otherwise, <c>false</c>.</value>
        [XmlElement]
        public Boolean ExtractIcon
        {
            get;
            set;
        }

    }
}